Skip to content

irremote: add a NEC transmitter - #898

Open
pottekkat wants to merge 1 commit into
tinygo-org:devfrom
pottekkat:nec-transmitter
Open

pottekkat wants to merge 1 commit into
tinygo-org:devfrom
pottekkat:nec-transmitter

Conversation

@pottekkat

Copy link
Copy Markdown
Contributor

Fixes #421

Adds a new SenderDevice. Moves the shared NEC timings and helpers to irremote/irprotocol.

Adapted from https://github.com/neildavis/drivers/tree/irremote-send.

Tested on ESP32-D0WD-V3 with a KY-005 IR LED and a KY-022.

Note: To test on the classic ESP32, you need this: tinygo-org/tinygo#5669, which is not part of the release at the time of writing.

Signed-off-by: Navendu Pottekkat <navendu@apache.org>
@deadprogram

Copy link
Copy Markdown
Member

Thanks for this. Looks good overall. A few small things:

  1. The stop channel is closed but nothing ever receives from it. It only works as a token for the repeat goroutine to see it was replaced. A simple counter would do the same job and be easier to follow.

  2. wait() busy loops on time.Now(), so timing accuracy depends on the clock resolution. On SAMD51 that is about 122µs (see irremote unreliable on SAMD51 #668), which is a big error on a 562.5µs mark. Fine on ESP32 and RP2040, but worth a short note in the docs.

  3. The API is a little uneven. SendNEC takes a byte command while the receiver Data.Command is uint16. Also SendNECRawCode and SendNECRepeat are exported and return a time.Duration that callers probably do not need.

  4. The extra NECZeroSpace after the trailing mark is not needed, since the carrier is already off at that point. It just adds 562.5µs to each frame.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add NEC protocol compliant sender to irremote

2 participants